<template>
  <div>
    <!-- 头部搜索部分 -->
    <div class="topBox">
      <van-icon name="arrow-left" color="#fffff" size="25" @click="$router.go(-1)" />
      <van-search v-model="value" placeholder="请输入搜索关键词" shape="round" @search="onSearch"></van-search>
      <van-icon name="apps-o" color="#fffff" size="25" @click="$router.push('/goods/filter')" />
    </div>
    <div class="sideTable">
      <!-- 侧边栏导航 -->
      <van-sidebar class="navAside" v-model="activeKey" @change="onChange">
        <van-sidebar-item v-for="(item, i) in className" :key="i" :title="item" />
      </van-sidebar>
      <!-- 主要内容区域 -->
      <div class="content" v-for="(item, i) in content" :key="i" v-if="i==activeKey">{{item}}</div>
    </div>
  </div>
</template>

<script>
export default {
  data() {
    return {
      // 搜索框绑定的数据
      value: "",
      // 侧边栏当前选项的索引
      activeKey: 0,
      // 侧边栏数组
      className: [
        "手机数码",
        "家用电器",
        "电脑办公",
        "计生情趣",
        "美妆护肤",
        "个护清洁",
        "汽车生活",
        "京东超市",
        "男装",
        "男鞋",
        "女装",
        "女鞋"
      ],
      // 内容数组
      content: [
        "手机数码内容",
        "家用电器内容",
        "电脑办公内容",
        "计生情趣内容",
        "美妆护肤内容",
        "个护清洁内容",
        "汽车生活内容",
        "京东超市内容",
        "男装内容",
        "男鞋内容",
        "女装内容",
        "女鞋内容"
      ]
    };
  },
  created() {},
  methods: {
    // 搜索框事件
    onSearch() {},
    // 侧边栏切换事件
    onChange(index) {
      this.activeKey = index;
    }
  }
};
</script>

<style lang="less" scoped>
.topBox {
  padding: 0 8px;
  display: flex;
  justify-content: space-around;
  border-bottom: 1.5px solid #ccc;
  .van-icon {
    flex: 5%;
    line-height: 56px;
    margin-left: 8px;
  }
  .van-search {
    flex: 95%;
  }
}
.sideTable {
  display: flex;
  justify-content: space-between;
  .van-sidebar {
    width: 150px;
  }
  .content {
    flex-grow: 1;
    // display: none;
  }
}
</style>